#!/bin/bash
if [ $# -eq 0 ]
then
    echo "input master/backup"
    exit 1
fi
case $1 in
master)
        sed -i "s/#laddr_group_name/laddr_group_name/" /etc/keepalived/keepalived.conf 2>/dev/null
        systemctl reload keepalived.service
;;
backup)
        if [ `grep "#laddr_group_name" /etc/keepalived/keepalived.conf|wc -l` -eq 0 ]
        then
            sed -i "s/laddr_group_name/#laddr_group_name/" /etc/keepalived/keepalived.conf 2>/dev/null
            systemctl reload keepalived.service
        fi
;;
esac